<?php require_once('connections/con_gl.php'); ?>
<?php
cekAkses($_SESSION[akses],"MS-8-1");
// get jenis kend
mysql_select_db($database_con_gl, $con_gl);
$query_jkend = "SELECT id, jenis from gl_jkendaraan order by jenis";
$jkend = mysql_query($query_jkend, $con_gl) or die(mysql_error());
$row_jkend = mysql_fetch_assoc($jkend);
$totalRows_jkend = mysql_num_rows($jkend);
// ---
// ---
mysql_select_db($database_con_gl, $con_gl);
$query_gudang = "SELECT id, gudang FROM gl_gudang";
if(!strstr($_SESSION[akses],'A-1-4')) {
	$query_gudang .= " where id='$_SESSION[lokasi]'";
}
$query_gudang .=" ORDER BY gudang ASC";
$gudang = mysql_query($query_gudang, $con_gl) or die(mysql_error());
$row_gudang = mysql_fetch_assoc($gudang);
$totalRows_gudang = mysql_num_rows($gudang);
?>
<link href="ccss/ui.datepicker.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="js/ui.datepicker.js"></script>
<script type="text/javascript">
<!--
$(function()
      {
        $('.calendar').datepicker({
            appendText : "",
            dateFormat : 'yy/mm/dd'
          });
      });
	  
</script>
<link type="text/css" rel="stylesheet" href="css/jquery.wysiwyg.css" />
<script type="text/javascript" src="js/jquery.wysiwyg.js"></script>
<script type="text/javascript">
$(document).ready(function() {

	$().ajaxStart(function() {
		$('#loading').show();
		$('#result').hide();
	}).ajaxStop(function() {
		$('#loading').hide();
		$('#result').fadeIn('slow');
	});

	$('#add').submit(function() {
		$.ajax({
			type: 'POST',
			url: $(this).attr('action'),
			data: $(this).serialize(),
			success: function(data) {
				$('#result').html(data);
			}
		})
		return false;
	});
  $('#result').click(function(){
  $(this).hide();
  });
})
$(function()
  {
	  $('#keterangan').wysiwyg();
  });
</script>
<script>
function sendRespondJenisService() {
	var ajaxRequest;  // The variable that makes Ajax possible!
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('divJenis');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
		if (ajaxRequest.readyState == 3) {
			var ajaxDisplay = document.getElementById('divJenis');
			ajaxDisplay.innerHTML = "<img src='images/ajax-loader.gif' />";
		}
	}
	ajaxRequest.open("GET", "include/send_respondjenisservice.php", true);
	ajaxRequest.send(null);	
}
</script>
<div id="loading" style="display:none;"><img src="images/loading.gif" alt="loading..." /></div>
<div id="result" style="display:none;"></div>
<h1>Tambah  Kendaraan</h1>
<form action="proses/masterservice.php?act=add" method="POST" name="add" id="add" >
  <table width="100%" border="0" align="center" cellpadding="5" cellspacing="0" class="datatable">
    <tr valign="top">
      <td width="20%" align="right" bgcolor="#FFFFFF">No. Polisi</td>
      <td width="80%" bgcolor="#FFFFFF"><label>
        <input name="nopol" type="text" id="nopol" size="10" maxlength="10" />
      </label></td>
    </tr>
    <tr>
      <td align="right" valign="top">Lokasi Kantor* :</td>
      <td valign="top"><label>
        <select name="gudang" id="gudang">
          <?php
do {  
?>
          <option value="<?php echo $row_gudang['id']?>"><?php echo $row_gudang['gudang']?></option>
          <?php
} while ($row_gudang = mysql_fetch_assoc($gudang));
  $rows = mysql_num_rows($gudang);
  if($rows > 0) {
      mysql_data_seek($gudang, 0);
	  $row_gudang = mysql_fetch_assoc($gudang);
  }
?>
        </select>
      </label></td>
    </tr>
    <tr valign="top">
      <td align="right" bgcolor="#FFFFFF">Jenis Kendaraan *: </td>
      <td bgcolor="#FFFFFF"><label id="divJenis">
        <select name="jenis" id="jenis">
          <option value="">Jenis Kendaraan</option>
          <?php if($totalRows_jkend > 0) { do { ?>
          <option value="<?php echo $row_jkend['id'];?>"><?php echo $row_jkend['jenis'];?></option>
          <?php }while($row_jkend = mysql_fetch_assoc($jkend)); } ?>
        </select>
      </label>
      <?php if(strstr($_SESSION['akses'],"JS-7-1")) { ?><a href="index.php?component=jenisservice&task=add&open=window" onclick="NewWindow(this.href,'name','825','420','yes');return false"><img src="images/add_.png" hspace="2" border="0" /></a><?php } ?></td>
    </tr>
    <tr valign="top">
      <td align="right" bgcolor="#FFFFFF">Tipe *:</td>
      <td bgcolor="#FFFFFF"><label>
        <input name="tipe" type="text" id="tipe" size="30" maxlength="100" />
      </label></td>
    </tr>
    <tr valign="top">
      <td align="right" bgcolor="#FFFFFF">Tahun *:</td>
      <td bgcolor="#FFFFFF"><label>
        <input name="tahun" type="text" id="tahun" size="5" maxlength="4" />
      </label></td>
    </tr>
    <tr valign="top">
      <td align="right" bgcolor="#FFFFFF">No. Rangka *:</td>
      <td bgcolor="#FFFFFF"><label>
        <input name="rangka" type="text" id="rangka" size="30" maxlength="100" />
      </label></td>
    </tr>
    <tr valign="top">
      <td align="right" bgcolor="#FFFFFF">No. Mesin *:</td>
      <td bgcolor="#FFFFFF"><label>
        <input name="mesin" type="text" id="mesin" size="30" maxlength="100" />
      </label></td>
    </tr>
    <tr valign="top">
      <td align="right" bgcolor="#FFFFFF">Tersedia :</td>
      <td bgcolor="#FFFFFF"><label>
        <input name="ada" type="checkbox" id="ada" value="1" checked="checked" />
      </label> 
      <small>Check jika tersedia</small></td>
    </tr>
    <tr valign="top">
      <td align="right" bgcolor="#FFFFFF">Masa Berlaku :</td>
      <td bgcolor="#FFFFFF">STNK : 
        <label>
          <input name="stnk" type="text" class="calendar" id="stnk" value="<?php echo date("Y/m/d");?>" size="15" maxlength="15"/>
      </label>
        KIR : <label>
          <input name="kir" type="text" class="calendar" id="kir" value="<?php echo date("Y/m/d");?>" size="15" maxlength="15"/>
      </label> Asuransi :<label>
          <input name="asuransi" type="text" class="calendar" id="asuransi" value="<?php echo date("Y/m/d");?>" size="20" maxlength="15"/>
      </label></td>
    </tr>
    <tr valign="top">
      <td align="right" bgcolor="#FFFFFF">Keterangan : </td>
      <td bgcolor="#FFFFFF"><textarea name="keterangan" cols="85" rows="5" id="keterangan"></textarea></td>
    </tr>
    
    <tr>
      <td align="left" bgcolor="#FFFFFF"><em>*Harus diisi 
        
          <input name="open" type="hidden" id="open" value="<?php echo $_GET['open'];?>" />
      </em></td>
      <td bgcolor="#FFFFFF"><label>
        <input name="Save" type="submit" id="Save" value="Simpan" />
        </label>
        <label>
          <input type="button" name="Button" value="Batal" onclick="javascript:<?php if($_GET['open']=='window') { ?>window.close(2000);<?php }else{ ?>history.go(-1);<?php } ?>" />
        </label></td>
    </tr>
  </table>
</form>
